package com.wzh.springbootinit.common;

import lombok.Data;

import java.io.Serializable;

/**
 * @Author wzh
 * @create 2023/3/31 20:37
 * @Description: 通用返回泛型类 T表示响应体类型
 */
@Data
public class BaseResponse<T> implements Serializable {
    private int code;

    private String message;
    //使用泛型做返回数据
    private T date;

    public BaseResponse(int code, String message, T date) {
        this.code = code;
        this.message = message;
        this.date = date;
    }

    public BaseResponse(int code, T date) {
        this(code,"",date);
    }

//    返回自定义常用
    public BaseResponse(ErrorCode errorCode) {
        this(errorCode.getCode(),errorCode.getMessage(),null);
    }

}
